home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / easyx / data1.cab / Example_Files / EX_7 / Form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-03  |  3.2 KB  |  111 lines

  1. VERSION 5.00
  2. Object = "{5A65A9C0-089F-11D2-88AD-0000B45C4CF6}#1.2#0"; "EASYX.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   2640
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   2850
  9.    Icon            =   "Form1.frx":0000
  10.    KeyPreview      =   -1  'True
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   2640
  13.    ScaleWidth      =   2850
  14.    StartUpPosition =   3  'Windows Default
  15.    Begin VB.Timer Timer1 
  16.       Interval        =   1
  17.       Left            =   240
  18.       Top             =   840
  19.    End
  20.    Begin PROJECTEXLibCtl.EasyX EasyX1 
  21.       Left            =   0
  22.       OleObjectBlob   =   "Form1.frx":014A
  23.       Top             =   0
  24.    End
  25. Attribute VB_Name = "Form1"
  26. Attribute VB_GlobalNameSpace = False
  27. Attribute VB_Creatable = False
  28. Attribute VB_PredeclaredId = True
  29. Attribute VB_Exposed = False
  30. Option Explicit
  31. Dim Sprite(29) As Long
  32. Dim SurfaceOne As Long
  33. Dim BackBuffer As Long
  34. Const SpriteWidth As Long = 64
  35. Const SpriteHeight As Long = 64
  36. 'Ending variable
  37. Dim Ending As Boolean
  38. Private Declare Function GetTickCount Lib "kernel32" () As Long
  39. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  40. Private Sub Form_Load()
  41. Dim rt As Long
  42. Dim AppPath As String
  43. Dim I As Integer, J As Integer
  44. EasyX1.Window = Me.hWnd
  45. AppPath = App.Path & "\"
  46. rt = EasyX1.IWInitDirectDraw(AppPath & "donut.bmp")
  47. SurfaceOne = EasyX1.LoadBitmapFile(AppPath & "donut.bmp", 0)
  48. If SurfaceOne <> 0 Then
  49.   MsgBox "surface failed", vbOKOnly
  50.     EasyX1.EndDirectX
  51.     Exit Sub
  52. End If
  53. 'create fake back buffer
  54. BackBuffer = EasyX1.IWCreateFakeBackBuffer(SpriteWidth, SpriteHeight)
  55. If BackBuffer < 0 Then
  56.     MsgBox "surface failed", vbOKOnly
  57.     EasyX1.EndDirectX
  58.     Exit Sub
  59. End If
  60. For I = 1 To 6
  61.     For J = 1 To 5
  62.       
  63.       Sprite((J - 1) + (I - 1) * 5) = EasyX1.MakeSprite( _
  64.                                            (J - 1) * SpriteWidth, _
  65.                                            (I - 1) * SpriteHeight, _
  66.                                            J * SpriteWidth, _
  67.                                            I * SpriteHeight, SurfaceOne)
  68.     Next J
  69. Next I
  70. RunMain
  71. End Sub
  72. Private Sub Form_Paint()
  73. 'Repaint and reload
  74. EasyX1.IWResetSurfaces
  75. End Sub
  76. Private Sub RunMain()
  77. Dim LastTick As Long
  78. Dim CurrentTick As Long
  79. Const TickDifference As Long = 10
  80. Dim I As Integer
  81. Me.Show
  82.     CurrentTick = GetTickCount()
  83.        
  84.     If CurrentTick - LastTick > TickDifference And Not Ending Then
  85.         LastTick = CurrentTick
  86.         
  87.         
  88.         
  89.         EasyX1.IWFillSurface 0, BackBuffer
  90.         'Draw to the fake back buffer
  91.         EasyX1.IWDrawToBackBuffer 0, 0, SpriteWidth, SpriteHeight, Sprite(I), BackBuffer
  92.         'Flip it
  93.         EasyX1.IWDrawFakeToPrimary BackBuffer
  94.         If I = 29 Then I = 0
  95.         I = I + 1
  96.     ElseIf Ending Then
  97.         
  98.         Exit Do
  99.              
  100.     Else
  101.         DoEvents
  102.         Sleep 10
  103.         
  104.     End If
  105.     DoEvents
  106. Unload Me
  107. End Sub
  108. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  109.     Ending = True
  110. End Sub
  111.